package co.edu.usbcali.presentation.businessDelegate;

import co.edu.usbcali.modelo.Cuenta;
import co.edu.usbcali.modelo.Persona;
import co.edu.usbcali.modelo.Retiro;
import co.edu.usbcali.modelo.Solicitud;
import co.edu.usbcali.modelo.Usuarios;
import co.edu.usbcali.modelo.Validacion;
import co.edu.usbcali.modelo.control.CuentaLogic;
import co.edu.usbcali.modelo.control.ICuentaLogic;
import co.edu.usbcali.modelo.control.IPersonaLogic;
import co.edu.usbcali.modelo.control.IRetiroLogic;
import co.edu.usbcali.modelo.control.ISolicitudLogic;
import co.edu.usbcali.modelo.control.IUsuariosLogic;
import co.edu.usbcali.modelo.control.IValidacionLogic;
import co.edu.usbcali.modelo.control.PersonaLogic;
import co.edu.usbcali.modelo.control.RetiroLogic;
import co.edu.usbcali.modelo.control.SolicitudLogic;
import co.edu.usbcali.modelo.control.UsuariosLogic;
import co.edu.usbcali.modelo.control.ValidacionLogic;
import co.edu.usbcali.modelo.dto.CuentaDTO;
import co.edu.usbcali.modelo.dto.PersonaDTO;
import co.edu.usbcali.modelo.dto.RetiroDTO;
import co.edu.usbcali.modelo.dto.SolicitudDTO;
import co.edu.usbcali.modelo.dto.UsuariosDTO;
import co.edu.usbcali.modelo.dto.ValidacionDTO;
import co.edu.usbcali.presentation.businessDelegate.IBusinessDelegatorView;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.context.annotation.Scope;

import org.springframework.stereotype.Service;

import java.math.BigDecimal;

import java.util.Date;
import java.util.List;
import java.util.Set;


/**
* Use a Business Delegate to reduce coupling between presentation-tier clients and business services.
* The Business Delegate hides the underlying implementation details of the business service, such as lookup and access details of the EJB architecture.
*
* The Business Delegate acts as a client-side business abstraction; it provides an abstraction for, and thus hides,
* the implementation of the business services. Using a Business Delegate reduces the coupling between presentation-tier clients and
* the system's business services. Depending on the implementation strategy, the Business Delegate may shield clients from possible
* volatility in the implementation of the business service API. Potentially, this reduces the number of changes that must be made to the
* presentation-tier client code when the business service API or its underlying implementation changes.
*
* However, interface methods in the Business Delegate may still require modification if the underlying business service API changes.
* Admittedly, though, it is more likely that changes will be made to the business service rather than to the Business Delegate.
*
* Often, developers are skeptical when a design goal such as abstracting the business layer causes additional upfront work in return
* for future gains. However, using this pattern or its strategies results in only a small amount of additional upfront work and provides
* considerable benefits. The main benefit is hiding the details of the underlying service. For example, the client can become transparent
* to naming and lookup services. The Business Delegate also handles the exceptions from the business services, such as java.rmi.Remote
* exceptions, Java Messages Service (JMS) exceptions and so on. The Business Delegate may intercept such service level exceptions and
* generate application level exceptions instead. Application level exceptions are easier to handle by the clients, and may be user friendly.
* The Business Delegate may also transparently perform any retry or recovery operations necessary in the event of a service failure without
* exposing the client to the problem until it is determined that the problem is not resolvable. These gains present a compelling reason to
* use the pattern.
*
* Another benefit is that the delegate may cache results and references to remote business services. Caching can significantly improve performance,
* because it limits unnecessary and potentially costly round trips over the network.
*
* A Business Delegate uses a component called the Lookup Service. The Lookup Service is responsible for hiding the underlying implementation
* details of the business service lookup code. The Lookup Service may be written as part of the Delegate, but we recommend that it be
* implemented as a separate component, as outlined in the Service Locator pattern (See "Service Locator" on page 368.)
*
* When the Business Delegate is used with a Session Facade, typically there is a one-to-one relationship between the two.
* This one-to-one relationship exists because logic that might have been encapsulated in a Business Delegate relating to its interaction
* with multiple business services (creating a one-to-many relationship) will often be factored back into a Session Facade.
*
* Finally, it should be noted that this pattern could be used to reduce coupling between other tiers, not simply the presentation and the
* business tiers.
*
* @author Zathura Code Generator http://code.google.com/p/zathura
*
*/
@Scope("singleton")
@Service("BusinessDelegatorView")
public class BusinessDelegatorView implements IBusinessDelegatorView {
    @Autowired
    private ICuentaLogic cuentaLogic;
    @Autowired
    private IPersonaLogic personaLogic;
    @Autowired
    private IRetiroLogic retiroLogic;
    @Autowired
    private ISolicitudLogic solicitudLogic;
    @Autowired
    private IUsuariosLogic usuariosLogic;
    @Autowired
    private IValidacionLogic validacionLogic;

    public List<Cuenta> getCuenta() throws Exception {
        return cuentaLogic.getCuenta();
    }

    public void saveCuenta(Cuenta entity) throws Exception {
        cuentaLogic.saveCuenta(entity);
    }

    public void deleteCuenta(Cuenta entity) throws Exception {
        cuentaLogic.deleteCuenta(entity);
    }

    public void updateCuenta(Cuenta entity) throws Exception {
        cuentaLogic.updateCuenta(entity);
    }

    public Cuenta getCuenta(Long idcuen) throws Exception {
        Cuenta cuenta = null;

        try {
            cuenta = cuentaLogic.getCuenta(idcuen);
        } catch (Exception e) {
            throw e;
        }

        return cuenta;
    }

    public List<Cuenta> findByCriteriaInCuenta(Object[] variables,
        Object[] variablesBetween, Object[] variablesBetweenDates)
        throws Exception {
        return cuentaLogic.findByCriteria(variables, variablesBetween,
            variablesBetweenDates);
    }

    public List<Cuenta> findPageCuenta(String sortColumnName,
        boolean sortAscending, int startRow, int maxResults)
        throws Exception {
        return cuentaLogic.findPageCuenta(sortColumnName, sortAscending,
            startRow, maxResults);
    }

    public Long findTotalNumberCuenta() throws Exception {
        return cuentaLogic.findTotalNumberCuenta();
    }

    public List<CuentaDTO> getDataCuenta() throws Exception {
        return cuentaLogic.getDataCuenta();
    }

    public List<Persona> getPersona() throws Exception {
        return personaLogic.getPersona();
    }

    public void savePersona(Persona entity) throws Exception {
        personaLogic.savePersona(entity);
    }

    public void deletePersona(Persona entity) throws Exception {
        personaLogic.deletePersona(entity);
    }

    public void updatePersona(Persona entity) throws Exception {
        personaLogic.updatePersona(entity);
    }

    public Persona getPersona(Long idpers) throws Exception {
        Persona persona = null;

        try {
            persona = personaLogic.getPersona(idpers);
        } catch (Exception e) {
            throw e;
        }

        return persona;
    }

    public List<Persona> findByCriteriaInPersona(Object[] variables,
        Object[] variablesBetween, Object[] variablesBetweenDates)
        throws Exception {
        return personaLogic.findByCriteria(variables, variablesBetween,
            variablesBetweenDates);
    }

    public List<Persona> findPagePersona(String sortColumnName,
        boolean sortAscending, int startRow, int maxResults)
        throws Exception {
        return personaLogic.findPagePersona(sortColumnName, sortAscending,
            startRow, maxResults);
    }

    public Long findTotalNumberPersona() throws Exception {
        return personaLogic.findTotalNumberPersona();
    }

    public List<PersonaDTO> getDataPersona() throws Exception {
        return personaLogic.getDataPersona();
    }

    public List<Retiro> getRetiro() throws Exception {
        return retiroLogic.getRetiro();
    }

    public void saveRetiro(Retiro entity) throws Exception {
        retiroLogic.saveRetiro(entity);
    }

    public void deleteRetiro(Retiro entity) throws Exception {
        retiroLogic.deleteRetiro(entity);
    }

    public void updateRetiro(Retiro entity) throws Exception {
        retiroLogic.updateRetiro(entity);
    }

    public Retiro getRetiro(Long idreti) throws Exception {
        Retiro retiro = null;

        try {
            retiro = retiroLogic.getRetiro(idreti);
        } catch (Exception e) {
            throw e;
        }

        return retiro;
    }

    public List<Retiro> findByCriteriaInRetiro(Object[] variables,
        Object[] variablesBetween, Object[] variablesBetweenDates)
        throws Exception {
        return retiroLogic.findByCriteria(variables, variablesBetween,
            variablesBetweenDates);
    }

    public List<Retiro> findPageRetiro(String sortColumnName,
        boolean sortAscending, int startRow, int maxResults)
        throws Exception {
        return retiroLogic.findPageRetiro(sortColumnName, sortAscending,
            startRow, maxResults);
    }

    public Long findTotalNumberRetiro() throws Exception {
        return retiroLogic.findTotalNumberRetiro();
    }

    public List<RetiroDTO> getDataRetiro() throws Exception {
        return retiroLogic.getDataRetiro();
    }

    public List<Solicitud> getSolicitud() throws Exception {
        return solicitudLogic.getSolicitud();
    }

    public void saveSolicitud(Solicitud entity) throws Exception {
        solicitudLogic.saveSolicitud(entity);
    }

    public void deleteSolicitud(Solicitud entity) throws Exception {
        solicitudLogic.deleteSolicitud(entity);
    }

    public void updateSolicitud(Solicitud entity) throws Exception {
        solicitudLogic.updateSolicitud(entity);
    }

    public Solicitud getSolicitud(Long idsoli) throws Exception {
        Solicitud solicitud = null;

        try {
            solicitud = solicitudLogic.getSolicitud(idsoli);
        } catch (Exception e) {
            throw e;
        }

        return solicitud;
    }

    public List<Solicitud> findByCriteriaInSolicitud(Object[] variables,
        Object[] variablesBetween, Object[] variablesBetweenDates)
        throws Exception {
        return solicitudLogic.findByCriteria(variables, variablesBetween,
            variablesBetweenDates);
    }

    public List<Solicitud> findPageSolicitud(String sortColumnName,
        boolean sortAscending, int startRow, int maxResults)
        throws Exception {
        return solicitudLogic.findPageSolicitud(sortColumnName, sortAscending,
            startRow, maxResults);
    }

    public Long findTotalNumberSolicitud() throws Exception {
        return solicitudLogic.findTotalNumberSolicitud();
    }

    public List<SolicitudDTO> getDataSolicitud() throws Exception {
        return solicitudLogic.getDataSolicitud();
    }

    public List<Usuarios> getUsuarios() throws Exception {
        return usuariosLogic.getUsuarios();
    }

    public void saveUsuarios(Usuarios entity) throws Exception {
        usuariosLogic.saveUsuarios(entity);
    }

    public void deleteUsuarios(Usuarios entity) throws Exception {
        usuariosLogic.deleteUsuarios(entity);
    }

    public void updateUsuarios(Usuarios entity) throws Exception {
        usuariosLogic.updateUsuarios(entity);
    }

    public Usuarios getUsuarios(Long idusuario) throws Exception {
        Usuarios usuarios = null;

        try {
            usuarios = usuariosLogic.getUsuarios(idusuario);
        } catch (Exception e) {
            throw e;
        }

        return usuarios;
    }

    public List<Usuarios> findByCriteriaInUsuarios(Object[] variables,
        Object[] variablesBetween, Object[] variablesBetweenDates)
        throws Exception {
        return usuariosLogic.findByCriteria(variables, variablesBetween,
            variablesBetweenDates);
    }

    public List<Usuarios> findPageUsuarios(String sortColumnName,
        boolean sortAscending, int startRow, int maxResults)
        throws Exception {
        return usuariosLogic.findPageUsuarios(sortColumnName, sortAscending,
            startRow, maxResults);
    }

    public Long findTotalNumberUsuarios() throws Exception {
        return usuariosLogic.findTotalNumberUsuarios();
    }

    public List<UsuariosDTO> getDataUsuarios() throws Exception {
        return usuariosLogic.getDataUsuarios();
    }

    public List<Validacion> getValidacion() throws Exception {
        return validacionLogic.getValidacion();
    }

    public void saveValidacion(Validacion entity) throws Exception {
        validacionLogic.saveValidacion(entity);
    }

    public void deleteValidacion(Validacion entity) throws Exception {
        validacionLogic.deleteValidacion(entity);
    }

    public void updateValidacion(Validacion entity) throws Exception {
        validacionLogic.updateValidacion(entity);
    }

    public Validacion getValidacion(Long idvali) throws Exception {
        Validacion validacion = null;

        try {
            validacion = validacionLogic.getValidacion(idvali);
        } catch (Exception e) {
            throw e;
        }

        return validacion;
    }

    public List<Validacion> findByCriteriaInValidacion(Object[] variables,
        Object[] variablesBetween, Object[] variablesBetweenDates)
        throws Exception {
        return validacionLogic.findByCriteria(variables, variablesBetween,
            variablesBetweenDates);
    }

    public List<Validacion> findPageValidacion(String sortColumnName,
        boolean sortAscending, int startRow, int maxResults)
        throws Exception {
        return validacionLogic.findPageValidacion(sortColumnName,
            sortAscending, startRow, maxResults);
    }

    public Long findTotalNumberValidacion() throws Exception {
        return validacionLogic.findTotalNumberValidacion();
    }

    public List<ValidacionDTO> getDataValidacion() throws Exception {
        return validacionLogic.getDataValidacion();
    }
}
